#pragma once

#include <iostream>
#include <ctime>
namespace mymq
{
    #define MYMQINFO    0
    #define MYMQDEBUG   1
    #define MYMQERROR   2
    #define MYMQFATAL   3

    #define LOG_LEVEL MYMQINFO

    #define LOG(level_str, level, format, ...) do{\
        if (level < LOG_LEVEL) break;\
        time_t t = time(nullptr);\
        struct tm* ptm = localtime(&t);\
        char time_str[32]{};\
        strftime(time_str, 31, "%H:%M:%S", ptm);\
        printf("[%s] [%s] [%s:%d] " format "\n", level_str, time_str, __FILE__, __LINE__, ##__VA_ARGS__);\
    } while(0)

    #define INFO_LOG(format, ...) LOG("INFO", MYMQINFO, format, ##__VA_ARGS__)
    #define DEBUG_LOG(format, ...) LOG("DEBUG", MYMQDEBUG, format, ##__VA_ARGS__)
    #define ERROR_LOG(format, ...) LOG("ERROR", MYMQERROR, format, ##__VA_ARGS__)
    #define FATAL_LOG(format, ...) LOG("FATAL", MYMQFATAL, format, ##__VA_ARGS__)
    }